Welcome to Motor Driver Section

Using Motor Driver to control the rolling direction and speed of the DC Motor!

Start scrolling!

Objective

The purpose of this lab is for you to change from manual to open loop control of the car. At the end of this lab, your car should be able to execute a pre-programmed series of moves, using the Artemis board and two dual motor drivers.

  • Solder the motor driver to Arduino
  • Install everything on the car
  • Use oscilloscope to get the PWM out of motor driver
  • Make the car forward, backward, turn direction in different speed

Task 1

Correctly connect motor drivers to the Arduino Board

The power supply of the motor driver comes from the battery, which is 3.7V, so the VIN pin should connect to the positive pin of the battery. Note that we could also use VMM as the positive power supply pin, but usually we use VIN pin to achieve this function.

All of the motor drivers' GND pins should be connected to the GND of the Arduino, this is to ensure the absolute voltage of Arduino board's gpio pin is consistent with our setting in the program.

Normally one motor driver could control two motors by using A1/2 IN and A1/2 OUT pins or B1/2 IN and B1/2 OUT pins. In which the number '1' and '2' controls the direction of the motor. For example, when A1 is high and A2 is low, the motor rolls in clock direction, then when A1 is low and A2 is high, the motor will roll in counter-clockwise direction.

And the PWM of the Input pin of the motor driver controls the speed/torque of the motor. To make our motor have a higher voltage to supply enough torque to make the car move, we connnect the A and B pins together, shown in the figure below.

Description of the image

Task 2

Assemble the car

Here is the planform of my car, I used some 3D printed compoents to(The white one in the figure) tightly assemble our board/sensors to the car, and more components will be introduced below.

Description of the image

At the front of the car, there are IMU and one TOF components to detect the roll,pitch,roll and the obstacles in front of the car.

Description of the image

There is another ToF sensor at the side of the car, shown in the figure below.

Description of the image

At the back of the car, i removed the cover of the battery holder and put the Arduino board and motor driver inside, this is to make sure we got more space so that all components could attached tightly to the car in case the car flips. In the same time, as shown below, the power supply port and USB-C port is easy to be connected.

Description of the image

Here below is a simple demonstration showing that the motor driver is under the Arduino board.

Description of the image

Task 3

Control the motion of the car

I used the following code to control the motion of the car, by changing the value of curr_speed, we could control the speed of the car, and by inversing the value of motorA_in1 and motorA_in2, we could change the rolling direction of the left motor, and same for the right motor.

Description of the image

And then I used the oscilloscope to monitor the output voltage of the motor driver when the wheel is rolling, the result is shown below:

Description of the image

Task 4

Open loop control

In this experiement, I found out that the required PWM for turning direction is more than that of going forward/backward. At first, I set both PWM to 70 and the car only go back and forth, cannot turning direction. Then I adjust the truning PWM to 2*forwardPWM = 140, in this case the car can turn direction quickly.

The video of open loop is shown below, the operation loop is forward -> stop -> turn right -> turn left -> forward.

And the code of the main loop is attached here:

Description of the image

Additional Task 1

Consider what frequency analogWrite generates. Is this adequately fast for these motors? Can you think of any benefits to manually configuring the timers to generate a faster PWM signal?

As shown in the figure below, when the PWM is 100 for analogWrite, the frequency(right-top) is about 227Hz. Because I cannot find the mannual for the motor that we use, so I have no idea whether this frequency is in its operation frequency range, but the car can run smoothly under this frequency, so I think this frequency is quite adequately fast for the motors.

Description of the image

If we could manually generate a faster PWM signal, it will help to reduce the influence caused by low frequency noise, and also the motor may gain more power to make the car run faster.

Additional Task 2

Relating to task 8 above, try to (experimentally) figure out not just at what PWM value the robot starts moving (forward and on-axis turns), but also the lowest PWM value at which you can keep the robot running once it is in motion. How quickly can you have the robot settle at its slowest speed? (First program a value that overcomes static friction and gets the robot moving, then a value that keeps it moving as slowly as possible.)

The result after testing the minimum PWM in different situations is shown in the table below

Description of the image